Phase 2: Refactor feed management from jQuery to HTMX#34
Draft
Phase 2: Refactor feed management from jQuery to HTMX#34
Conversation
Co-authored-by: cubny <172368+cubny@users.noreply.github.com>
Co-authored-by: cubny <172368+cubny@users.noreply.github.com>
Co-authored-by: cubny <172368+cubny@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor feed management to use HTMX without jQuery
Phase 2: Refactor feed management from jQuery to HTMX
Nov 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates feed add/list/delete operations from jQuery AJAX to HTMX while preserving JSON API backward compatibility. Backend now detects HTMX requests via
HX-Requestheader and returns HTML fragments; non-HTMX requests still receive JSON.Backend Changes
New fragment renderer (
fragments_feed.go):renderFeedRow()- Single feed HTMLrenderFeedList()- Complete list including static Unread/Starred feedsrenderFeedError()- Error message fragmentsDual-mode handlers (
feed.go):Form data support (
model.go): Handlers now accept bothapplication/jsonandapplication/x-www-form-urlencodedFrontend Changes
HTMX form (
index.html):Removed jQuery AJAX (
feeds.js): Replaced$.ajax()calls with HTMX for add/delete, vanillafetch()for readsAuth configuration (
main.js):Known Issue
Testing
Updated
MainPage.jsto submit form via Enter key instead of double-click pattern. Backend unit tests pass. UI tests blocked by auth issue above.Original prompt
Phase 2: Refactor Feed Management with HTMX (No htmx-go)
Refactor the feed management portion of the application to eliminate all jQuery / jQuery-UI usage and migrate interactions to HTMX while preserving existing JSON API behavior for non-HTMX requests. This phase focuses ONLY on feed-related functionality and must maintain full test parity (Playwright feed tests) and code quality (lint passes). Do NOT integrate
htmx-go; use the existing backend architecture (httprouter handlers, middleware chain) and manual detection of HTMX via theHX-Requestheader.Scope
Constraints & Principles
isHTMX := r.Header.Get("HX-Request") == "true".public/js/feeds.js.make lintafter backend changes and fix all issues.Backend Tasks
internal/infra/http/api/feed.go(and any related handlers):Content-Type: text/html; charset=utf-8and write fragment HTML only.internal/infra/http/api/fragments_feed.go) such as:renderFeedRow(f *feed.Feed) stringrenderFeedList(feeds []*feed.Feed) stringrenderFeedStatus(msg string, kind string) string(kind = success|error)<div class="feed-error">...</div>).!isHTMX.hx-swapstrategies; if removal causes an empty list, return an empty state fragment.Frontend Tasks (public/ directory)
hx-post="/feeds".hx-target="#feeds-list"(or appropriate container ID).hx-swap="innerHTML"(or suitable strategy).id="feed-add-indicator"and includehx-indicator="#feed-add-indicator"on the form.hx-put="/feeds/{id}/fetch"with dynamic ID.hx-target="#feed-row-{id}".hx-swap="outerHTML"to replace the entire row.hx-delete="/feeds/{id}".hx-target="#feeds-list"with server returning a new list or status fragment.<div class="feed-empty">No feeds added yet</div>fragment.public/js/feeds.jsONLY if logic > 3 lines is needed (e.g., small utility for progressive enhancement). Keep it minimal and documented.HTML / Fragment Guidelines
<html>/<body>wrappers).<div id="feed-row-{{.ID}}" class="feed-row">for targeting.Testing Requirements
npm run test:ui tests/ui/feeds.spec.js(ormake test-ui) after changes; MUST pass 100%.tests/ui/pages/) consistently.Linting & Quality
make lintafter backend modifications; resolve all issues.go mod tidyonly if imports were added/removed (expect no new module for HTMX server handling).Deliverables
public/js/feeds.js(only if >3 lines of JS needed) with inline comments explaining necessity.This pull request was created as a result of the following prompt from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.